package com.example.manage_dzensaas.filter;

import org.noear.solon.annotation.Component;
import org.noear.solon.core.handle.Context;
import org.noear.solon.core.handle.Filter;
import org.noear.solon.core.handle.FilterChain;

/**
 * @author wangzhiqi
 * @version 1.0
 * @description: 统一请求前缀过滤器
 * @date 2025/1/9 14:07
 */
@Component
public class RootPathFilter implements Filter {
    @Override
    public void doFilter(Context ctx, FilterChain chain) throws Throwable {
        // 忽略 /favicon.ico 请求
        if ("/favicon.ico".equals(ctx.path())) {
            ctx.status(404);
            return;
        }
        // 忽略 /doc.html 请求
        if ("/doc.html".equals(ctx.path())) {
            ctx.status(404);
            return;
        }
        if ("/".equals(ctx.path())) {
            ctx.status(404);
            return;
        }
        // 继续执行后续逻辑
        chain.doFilter(ctx);
    }
}
